package com.zj.controller;


import com.zj.pojo.Apple;
import com.zj.pojo.Result;
import com.zj.pojo.Teachure;
import com.zj.services.AppleService;
import com.zj.services.TeacherService;
import com.zj.tool.SpringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/teacher")
public class TeacherController {
    private static Logger log = LoggerFactory.getLogger(TeacherController.class);


    @Autowired
    private TeacherService service;

    @Autowired
    private SpringUtil util;
    @GetMapping("/{id}")
    public Result getApple(@PathVariable int id) {
        log.info("请求getApple进入" + id);
        Teachure apple = service.getAppleById(id);
        return new Result(HttpStatus.OK.value(), "query success", apple);
    }
    @GetMapping("/all")
    public Result getAll(){
        log.info("请求getAll进入");
        AppleService bean = util.getBean(AppleService.class);
        TeacherService bean2 = util.getBean(TeacherService.class);

        List<Teachure> apppool1 = service.getApppool();
        return new Result<>(HttpStatus.OK.value(), "query all success", apppool1);
    }
}
